package com.assessment.servermanager.controller;


import com.assessment.servermanager.commen.controller.BaseController;
import com.assessment.servermanager.commen.entity.AjaxResult;
import com.assessment.servermanager.commen.page.TableDataInfo;
import com.assessment.servermanager.entity.TbDept;
import com.assessment.servermanager.service.ITbDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author jiajia
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/dept")
public class TbDeptController extends BaseController {
    @Autowired
    private ITbDeptService tbDeptService;

    /**
     * 查询【请填写功能名称】列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TbDept tbDept) {

        List<TbDept> list = tbDeptService.selectTbDeptList(tbDept);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbDept tbDept) {
    /*    List<TbDept> list = tbDeptService.selectTbDeptList(tbDept);
        ExcelUtil<TbDept> util = new ExcelUtil<TbDept>(TbDept.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");*/
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(tbDeptService.selectTbDeptById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping
    public AjaxResult add(@RequestBody TbDept tbDept) {
        return toAjax(tbDeptService.insertTbDept(tbDept));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PutMapping
    public AjaxResult edit(@RequestBody TbDept tbDept) {
        return toAjax(tbDeptService.updateTbDept(tbDept));
    }

    /**
     * 删除【请填写功能名称】
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tbDeptService.deleteTbDeptByIds(ids));
    }
}
